﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using System.Data;
using System.Data.SqlClient;

namespace QLHS
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            //Application.EnableVisualStyles();
            //Application.SetCompatibleTextRenderingDefault(false);
            //Application.Run(new Form1());
            HocSinh p = new HocSinh();
            p.NhapHocSinh();
        }
    }
    public class HocSinh
    {
        protected string m_MaHS;
        protected string m_HoTen;
        //protected string NgaySinh;
        // protected bool Phai;
        protected string m_DiaChi;
        protected string m_MaLop;
        protected int m_NienKhoa;
        public HocSinh()
        {
            m_MaHS = "0611";
            m_HoTen = "Nguyen Van A";
            // NgaySinh = "11/01/1992";
            // Phai = true;
            m_DiaChi = "TPHCM";
            m_MaLop = "12A1";
            m_NienKhoa = 2001;
        }
        public void NhapHocSinh()
        {
            string connectionString = "Data Source=PC-200908251039;Initial Catalog=QLHSPT1H;Integrated Security=True";
            SqlConnection conn = new SqlConnection(connectionString);
            string commandText = "insert into HOCSINH(MaHS, MaLop, NienKhoa)" +
                                 "values (@MaHS, @MaLop, @NienKhoa)";
            SqlCommand comm = new SqlCommand(commandText, conn);
            comm.Parameters.Add("@MaHS", SqlDbType.VarChar, 7);
            comm.Parameters["@MaHS"].Value = m_MaHS;
            comm.Parameters.Add("@MaLop", SqlDbType.VarChar, 4);
            comm.Parameters["@MaLop"].Value = m_MaLop;
            comm.Parameters.Add("@NienKhoa", SqlDbType.Int);
            comm.Parameters["@NienKhoa"].Value = m_NienKhoa;
            conn.Open();
            comm.ExecuteNonQuery();
            conn.Close();
        }
    }
}
